﻿@model SPagedList<Dyd.BaseService.ServiceCenter.Domain.Model.tb_system_config>
@{
    ViewBag.Title = "系统配置";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@Html.AntiForgeryToken()
<div class="main_content">
    <div class="top">
        <h3>@ViewBag.Title</h3>
    </div>
    <div class="box ml10">
        @Html.ActionLink("新增", "SystemConfigCreate", "SystemConfig", null, new { @class = "btn", id = "addLink" })
    </div>
    <div class="main">
        @using (Ajax.BeginForm("SystemConfigIndex", "SystemConfig", null, new AjaxOptions { UpdateTargetId = "ajaxList", InsertionMode = InsertionMode.Replace }, new { id = "ajaxForm" }))
        {
            <div class="pt10">
                <label>键</label>
                <input value="" type="text" name="key" id="key" style="width:150px;" maxlength="15" />
                <label>值</label>
                <input value="" type="text" name="value" id="value" style="width:150px;" maxlength="15" />
                <label>备注</label>
                <input value="" type="text" name="remark" id="remark" style="width:150px;" maxlength="15" />
                <input type="submit" class="btn" value="搜索" accesskey="S" />
            </div>
        }
    </div>

    <div id="ajaxList" class="m10">
        @Html.Partial("_SystemConfigIndex", Model)
    </div>
</div>
@section Scripts{
}

@section footerScripts{
    @Html.SPagerScript()
    <script>

        $(function () {

            $("#ajaxList").on("click", function (event) {
                var type = $(event.target).attr("class");
                switch (type) {
                    case "editItem": editItem(event.target); break;
                    case "deleteItem": deleteItem(event.target); break;
                }
            });
        });

        //编辑
        function editItem(obj) {
            var id = $(obj).parent().parent().attr("data-id");
            var url = "/SystemConfig/SystemConfigEdit/" + id;
            window.location.href = url;
        }

        //删除
        function deleteItem(obj) {
            var id = $(obj).parent().parent().attr("data-id");
            if (confirm("确认删除")) {
                $.ajax({
                    url: "/SystemConfig/SystemConfigDelete",
                    type: "post",
                    data: antiToken({ id: id }),
                    dataType: "json",
                    success: function (data) {
                        if (data.Flag) {
                            alert(data.Message);
                            window.location.reload();
                        } else {
                            alert(data.Message);
                        }
                    }
                });
            }
        }
    </script>
}